﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Entities
{
    public static class Extensions
    {
        public static bool IsNumber(this string str)
        {
            double num;
            return double.TryParse(str, out num);
        }

        public static bool IsInt(this string str)
        {
            int num;
            return int.TryParse(str, out num);
        }

        public static double? ToNumber(this string str)
        {
            double num;

            if (double.TryParse(str, out num))
            {
                return num;
            }

            return null;
        }

        public static int? ToInt(this string str)
        {
            int num;

            if (int.TryParse(str, out num))
            {
                return num;
            }

            return null;
        }

        public static decimal? ToDecimal(this string str)
        {
            decimal num;

            if (decimal.TryParse(str, out num))
            {
                return num;
            }

            return null;
        }
    }
}
